﻿// Ini.cpp : 定义应用程序的入口点。
//

#include "framework.h"
#include "Ini.h"

int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
    _In_opt_ HINSTANCE hPrevInstance,
    _In_ LPWSTR    lpCmdLine,
    _In_ int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    LPCSTR appName = "Directories";
    LPCSTR keyName[] = { "GameDataDir", "WorldDir", "BGDir", "TrackDir", "AudioDir", "SFXAudioDir", "CinematDir" };
    LPCSTR subDir[] = { "GameData", "Worlds", "Bkgnd", "Tracks", "Audio", "Audio", "Cinemats" };
    char fileName[MAX_PATH] = { 0 };

    char string[MAX_PATH] = { 0 };
    char currentDir[MAX_PATH] = { 0 };
    GetCurrentDirectoryA(MAX_PATH, currentDir);
    strcpy_s(fileName, MAX_PATH, currentDir);
    strcat_s(fileName, MAX_PATH, "\\");
    strcat_s(fileName, MAX_PATH, "RtKrondor.ini");

    for (int i = 0; i < 7; i++)
    {
        strcpy_s(string, MAX_PATH, currentDir);
        strcat_s(string, MAX_PATH, "\\");
        strcat_s(string, MAX_PATH, subDir[i]);
        strcat_s(string, MAX_PATH, "\\");
        WritePrivateProfileStringA(appName, keyName[i], string, fileName);
    }
}
